package com.todod.base.module.infra.dal.mysql.baseofficialletter;

import java.util.*;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.todod.base.framework.common.pojo.PageResult;
import com.todod.base.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.todod.base.framework.mybatis.core.mapper.BaseMapperX;
import com.todod.base.module.infra.dal.dataobject.baseofficialletter.BaseOfficialLetterDO;
import org.apache.ibatis.annotations.Mapper;
import com.todod.base.module.infra.controller.admin.baseofficialletter.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 公函 Mapper
 *
 * @author 平台管理员
 */
@Mapper
public interface BaseOfficialLetterMapper extends BaseMapperX<BaseOfficialLetterDO> {

    default PageResult<BaseOfficialLetterDO> selectPage(BaseOfficialLetterPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BaseOfficialLetterDO>()
                .eqIfPresent(BaseOfficialLetterDO::getTheme, reqVO.getTheme())
                .eqIfPresent(BaseOfficialLetterDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(BaseOfficialLetterDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BaseOfficialLetterDO::getPublishTime, reqVO.getPublishTime())
                .eqIfPresent(BaseOfficialLetterDO::getStatus, reqVO.getStatus())
                .orderByDesc(BaseOfficialLetterDO::getId));
    }

    IPage<BaseOfficialLetterDO> getEffectOfficialLetterPage(IPage<BaseOfficialLetterDO> page, @Param("queryEntry") BaseOfficialLetterPageReqVO reqVO);

    default PageResult<BaseOfficialLetterDO> getInvalidOfficialLetterPage(BaseOfficialLetterPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BaseOfficialLetterDO>()
                .eqIfPresent(BaseOfficialLetterDO::getTheme, reqVO.getTheme())
                .eqIfPresent(BaseOfficialLetterDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(BaseOfficialLetterDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BaseOfficialLetterDO::getPublishTime, reqVO.getPublishTime())
                .eqIfPresent(BaseOfficialLetterDO::getStatus, reqVO.getStatus())
                .neIfPresent(BaseOfficialLetterDO::getStatus, 0)
                .orderByDesc(BaseOfficialLetterDO::getId));
    }

}